from alipay import AliPay

from taotao.settings import ali_pub_key_path, ali_private_key_path

def ali_init():
    app_private_key_string = open(ali_private_key_path).read()
    alipay_public_key_string = open(ali_pub_key_path).read()
    app_id = "2016100100643237"  # 复制来自支付宝生成的id
    notify_url = "http://192.168.1.5:8000/aliback"

    alipay = AliPay(
        appid=app_id,
        app_notify_url= notify_url,  # 默认回调urlnotify_url
        app_private_key_string=app_private_key_string,
        alipay_public_key_string=alipay_public_key_string,  # 支付宝的公钥，验证支付宝回传消息使用，不是你自己的公钥,
        sign_type="RSA2",  # RSA 或者 RSA2
        debug=True  # 默认False
    )
    return alipay
